package model;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

import model.entities.Direction;
import model.entities.LaserSource;
import model.entities.Mirror;

public class Bin {

	private List<Mirror> mirrorList = new ArrayList<Mirror>();
	private List<LaserSource> redSourceList = new ArrayList<LaserSource>();
	private List<LaserSource> greenSourceList = new ArrayList<LaserSource>();
	private List<LaserSource> blueSourceList = new ArrayList<LaserSource>();
	
	/**
	 * Empty Bin
	 */
	public Bin() {
		
	}
	
	public Bin(int numMirrors, int numRedSources, int numGreenSources, int numBlueSources) {
		
		for (int i = 0; i < numMirrors; i++) {
			mirrorList.add(new Mirror());
		}
		for (int i = 0; i < numRedSources; i++) {
			redSourceList.add(new LaserSource(Color.RED, Direction.TOP));
		}
		for (int i = 0; i < numGreenSources; i++) {
			greenSourceList.add(new LaserSource(Color.GREEN, Direction.TOP));
		}
		for (int i = 0; i < numBlueSources; i++) {
			blueSourceList.add(new LaserSource(Color.BLUE, Direction.TOP));
		}

	}
	
	public int getMirrorCount() {
		return mirrorList.size();
	}
	
	public int getRedSourceCount() {
		return redSourceList.size();
	}
	
	public int getGreenSourceCount() {
		return greenSourceList.size();
	}
	
	public int getBlueSourceCount() {
		return blueSourceList.size();
	}
	
	public Mirror takeMirror() {
		if(getMirrorCount() == 0)
			return null;
		Mirror mirror = mirrorList.get(0);
		mirrorList.remove(0);
		return mirror;
	}
	
	public void putMirror() { // maybe I can pass the entity in here..
		Mirror mirror = new Mirror();
		mirrorList.add(mirror);
	}

	public LaserSource takeRedLaserSource() {
		if (getRedSourceCount() == 0)
			return null;
		LaserSource source = redSourceList.get(0);
		redSourceList.remove(0);
		return source;
	}
	
	public LaserSource takeGreenLaserSource() {
		if (getGreenSourceCount() == 0)
			return null;
		LaserSource source = greenSourceList.get(0);
		greenSourceList.remove(0);
		return source;
	}
	
	public LaserSource takeBlueLaserSource() {
		if (getBlueSourceCount() == 0)
			return null;
		LaserSource source = blueSourceList.get(0);
		blueSourceList.remove(0);
		return source;
	}
	
	public void putRedSource() {
		LaserSource source = new LaserSource(Color.RED,Direction.TOP);
		redSourceList.add(source);
	}
	
	public void putGreenSource() {
		LaserSource source = new LaserSource(Color.GREEN,Direction.TOP);
		greenSourceList.add(source);
	}
	
	public void putBlueSource() {
		LaserSource source = new LaserSource(Color.BLUE,Direction.TOP);
		blueSourceList.add(source);
	}
	
}
